🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / map / src / commonMain / kotlin / org / meshtastic / feature / map / tiles / CustomTileProviderConfig.kt
Displaying Raw • Download
feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/tiles/CustomTileProviderConfig.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 3.54 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map.tiles
Tff7b72import T7ee787kotlinx.serialization.Serializable
Tff7b72import T7ee787kotlin.uuid.Uuid
Tf0883e@Serializable
Tff7b72data Tff7b72class T56d364CustomTileProviderConfigTb4b4b4(
Tff7b72val Te6edf3idTb4b4b4: Tffa657String Tff7b72= Te6edf3UuidTb4b4b4.Te6edf3randomTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)Tb4b4b4,
Tff7b72val Te6edf3nameTb4b4b4: Tffa657StringTb4b4b4,
Tff7b72val Te6edf3urlTemplateTb4b4b4: Tffa657StringTb4b4b4,
Tff7b72val Te6edf3localUriTb4b4b4: Tffa657String? Tff7b72= Tff7b72nullTb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3isLocalTb4b4b4: Tffa657Boolean
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3localUri Tff7b72!Tff7b72= Tff7b72null
Tff7b72fun Td2a8ffnormalizedTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3CustomTileProviderConfig Tff7b72= Te6edf3copyTb4b4b4(Te6edf3name Tff7b72= Te6edf3nameTb4b4b4.Te6edf3trimTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3urlTemplate Tff7b72= Te6edf3urlTemplateTb4b4b4.Te6edf3trimTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
T8b949e/**
* Whether a tile URL template is one we are willing to request.
*
* Hand-parsed rather than handed to a URL type, because there is no URL parser in common code and the rules here are
* narrow: a scheme we accept, a host, no credentials, no fragment, and every placeholder accounted for. The template
* belongs to the user, so the checks exist to keep a typo from being sent to a server as though it were a real request,
* not to defend against the person who typed it.
*
* A private/link-local host blocklist is intentionally omitted: the user supplies the tile endpoint, requests carry no
* Meshtastic-held credentials, and client-side tile GETs make that SSRF shape an accepted low-risk case.
*/
Tff7b72fun Te6edf3StringTb4b4b4.Td2a8ffisValidTileUrlTemplateTb4b4b4(Te6edf3requireHttpsTb4b4b4: Tffa657BooleanTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72val Te6edf3resolved Tff7b72= Te6edf3resolvedForValidationTb4b4b4(Tb4b4b4) Tff7b72?: Tff7b72return Tff7b72false
Tff7b72return Te6edf3resolvedTb4b4b4.Te6edf3hasAcceptedSchemeTb4b4b4(Te6edf3requireHttpsTb4b4b4) Tff7b72&Tff7b72& Te6edf3resolvedTb4b4b4.Te6edf3hasUsableAuthorityTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/**
* The template with our placeholders filled in, or null if it still holds one we cannot fill.
*
* A leftover `{apiKey}` is the common case: half-finished, and it would be sent to the server with braces intact.
*/
Tff7b72private Tff7b72fun Te6edf3StringTb4b4b4.Td2a8ffresolvedForValidationTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657String? Tb4b4b4{
Tff7b72val Te6edf3hasPlaceholders Tff7b72=
Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ff{z}Ta5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4) Tff7b72&Tff7b72& Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ff{x}Ta5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4) Tff7b72&Tff7b72& Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ff{y}Ta5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4)
Tff7b72val Te6edf3resolved Tff7b72=
Te6edf3replaceTb4b4b4(Ta5d6ff"Ta5d6ff{s}Ta5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffaTa5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4)
Tb4b4b4.Te6edf3replaceTb4b4b4(Ta5d6ff"Ta5d6ff{z}Ta5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff0Ta5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4)
Tb4b4b4.Te6edf3replaceTb4b4b4(Ta5d6ff"Ta5d6ff{x}Ta5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff0Ta5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4)
Tb4b4b4.Te6edf3replaceTb4b4b4(Ta5d6ff"Ta5d6ff{y}Ta5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff0Ta5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4)
Tff7b72return Te6edf3resolvedTb4b4b4.Te6edf3takeIf Tb4b4b4{ Te6edf3hasPlaceholders Tff7b72&Tff7b72& Ta5d6ff'{' Tff7b72!in Tffa657it Tff7b72&Tff7b72& Ta5d6ff'}' Tff7b72!in Tffa657it Tff7b72&Tff7b72& Tffa657itTb4b4b4.Te6edf3noneTb4b4b4(Tffa657CharTff7b72::Te6edf3isWhitespaceTb4b4b4) Tb4b4b4}
Tb4b4b4}
Tff7b72private Tff7b72fun Te6edf3StringTb4b4b4.Td2a8ffhasAcceptedSchemeTb4b4b4(Te6edf3requireHttpsTb4b4b4: Tffa657BooleanTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72val Te6edf3scheme Tff7b72= Te6edf3substringBeforeTb4b4b4(Te6edf3SCHEME_SEPARATORTb4b4b4, Te6edf3missingDelimiterValue Tff7b72= Ta5d6ff"Ta5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3lowercaseTb4b4b4(Tb4b4b4)
Tff7b72return Tff7b72if Tb4b4b4(Te6edf3requireHttpsTb4b4b4) Te6edf3scheme Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffhttpsTa5d6ff" Tff7b72else Te6edf3scheme Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffhttpTa5d6ff" Tff7b72|Tff7b72| Te6edf3scheme Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffhttpsTa5d6ff"
Tb4b4b4}
T8b949e/** A host, no fragment, and no credentials — those would be persisted in the clear and sent with every tile. */
Tff7b72private Tff7b72fun Te6edf3StringTb4b4b4.Td2a8ffhasUsableAuthorityTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72val Te6edf3afterScheme Tff7b72= Te6edf3substringAfterTb4b4b4(Te6edf3SCHEME_SEPARATORTb4b4b4)
Tff7b72val Te6edf3authority Tff7b72= Te6edf3afterSchemeTb4b4b4.Te6edf3substringBeforeTb4b4b4(Ta5d6ff'/'Tb4b4b4)Tb4b4b4.Te6edf3substringBeforeTb4b4b4(Ta5d6ff'?'Tb4b4b4)
Tff7b72return Ta5d6ff'#' Tff7b72!in Te6edf3afterScheme Tff7b72&Tff7b72& Ta5d6ff'@' Tff7b72!in Te6edf3authority Tff7b72&Tff7b72& Te6edf3authorityTb4b4b4.Te6edf3substringBeforeTb4b4b4(Ta5d6ff':'Tb4b4b4)Tb4b4b4.Te6edf3isNotBlankTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tff7b72private Tff7b72const Tff7b72val Te6edf3SCHEME_SEPARATOR Tff7b72= Ta5d6ff"Ta5d6ff://Ta5d6ff"
Served by rngit 1.5.2 - Generated in 0.09s